library(tidyverse)

#Data of Google Trends
trend_ds <- read.csv("trend_downing_street.csv")
trend_cp <- read.csv("trend_christmasparty.csv")


trend_ds <- trend_ds |> mutate(
  date_2=as_date(date)
)

trend_cp <- trend_cp |> mutate(
  date_2=as_date(date)
)

#Figure B1
gg_trend_ds <- trend_ds |> ggplot()+
  geom_line(aes(x=date_2,y=trend),linewidth=1)+
  geom_label(aes(x=as_date("2021-12-23"),y=99,label="Video Released"),size=6)+
  geom_label(aes(x=as_date("2021-11-17"),y=99,label="First Coverage"),size=6)+
  
  labs(x="Date",y="Trends of 'Downing Street'")+
  geom_vline(xintercept = as_date("2021-11-30"),linetype=2)+
  geom_vline(xintercept = as_date("2021-12-07"),linetype=2)+
  theme_minimal()+
  theme(text = element_text(size=24))
gg_trend_ds

#Figure B2
gg_trend_cp <- trend_cp |> ggplot()+
  geom_line(aes(x=date_2,y=trend),linewidth=1)+
  geom_label(aes(x=as_date("2021-12-23"),y=99,label="Video Released"),size=6)+
  geom_label(aes(x=as_date("2021-11-17"),y=99,label="First Coverage"),size=6)+
  
  labs(x="Date",y="Trends of 'Christmas Party'")+
  geom_vline(xintercept = as_date("2021-11-30"),linetype=2)+
  geom_vline(xintercept = as_date("2021-12-07"),linetype=2)+
  theme_minimal()+
  theme(text = element_text(size=24))
gg_trend_cp

ggsave("gtrend_ds.eps",gg_trend_ds,width = 10, height = 5, dpi = 1200,bg = "white")
ggsave("gtrend_cp.eps",gg_trend_cp,width = 10, height = 5, dpi = 1200,bg = "white")
